using System.Windows.Forms;
using Belmost4PDA.Constants;
using Belmost4PDA.Fasade;

namespace Belmost4PDA.Logic
{
    public class Control_Button : Control_PanelControl
    {
        private readonly Button button = new Button();
        public Control_Button(PanelItem paramItem):base(paramItem)
        {
            button.Text = paramItem.Caption;
            button.Click += button_Click;
            button.Tag = paramItem;
            //ParentID = paramItem.IDParent;
            //todo: Create Commnad for button
        }

        public static void button_Click(object sender, System.EventArgs e)
        {
            if(InterfaceDispatcher.CurrentPanel != -1)
            {
                InterfaceDispatcher.IDs.Push(InterfaceDispatcher.CurrentPanel);
            }
            InterfaceDispatcher.SetPanel( ((PanelItem)  ((Button)sender).Tag).IDPanel);
        }

        public override string GetControlType()
        {
            return ControlType.Button;
        }

        public override AbstractMapper GetMapper()
        {
            return null;
        }

        public override Control GetFormControl()
        {
            return button;
        }

        public override string GetCaption()
        {
            return "";
        }
    }
}
